/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.dao.impl;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.mycompany.entity.Student;
import java.util.List;
import com.mycompany.dao.StudentDAO;

/**
 *
 * @Created on 16-Mar-2009, 17:14:47
 * @author Wenbo.Sun
 */
public class StudentDAOImpl extends HibernateDaoSupport implements StudentDAO {

    public void save(Student student) {
		try {
			this.getHibernateTemplate().save(student);
		} catch (RuntimeException re) {
			throw re;
		}
	}

    public Student getById(String id) {
		try {
			Student student = (Student) getSession().get("com.mycompany.entity.Student", id);
			return student;
		} catch (RuntimeException re) {
			throw re;
		}
	}

    @SuppressWarnings("unchecked")
	public List<Student> getAll() {
		try {
			String query = "from Student student order by student.studentNumber";
			List<Student> list = this.getHibernateTemplate().find(query);
			return list;
		} catch (RuntimeException re) {
			throw re;
		}
	}

}
